var sliderWidth = 96; // 需要设置slider的宽度，用于计算中间位置

Page({
    data: {
        tabs: ["我送出的", "我收到的", "我参与的"],
        activeIndex: 0,
        sliderOffset: 0,
        sliderLeft: 0,
        launchOrder: [{
            orderId: '12739821738',
            orderStatus: '已完成',
            src: 'http://md.mrxiexie.cn/song/180731/1H7LLFFcID.jpg',
            name: '三只松鼠 约辣辣条200g',
            price: '9.80',
            netWeight: '200g×1盒',
            count: '1',
            username: '花花'
        }, {
            orderId: '12312390907',
            orderStatus: '已完成',
            src: 'http://md.mrxiexie.cn/song/180731/1H7LLFFcID.jpg',
            name: '三只松鼠 约辣辣条200g',
            price: '9.80',
            netWeight: '200g×1盒',
            count: '1',
            username: '花花'
        }],
        obtainOrder: [{
            orderId: '12y73891273',
            orderStatus: '已完成',
            src: 'http://md.mrxiexie.cn/song/180731/1H7LLFFcID.jpg',
            name: '三只松鼠 约辣辣条200g',
            price: '9.80',
            netWeight: '200g×1盒',
            count: '1',
            username: '花花'
        }],
        partakeOrder: [{
            orderId: '91283989181',
            orderStatus: '已完成',
            src: 'http://md.mrxiexie.cn/song/180731/1H7LLFFcID.jpg',
            name: '三只松鼠 约辣辣条200g',
            price: '9.80',
            netWeight: '200g×1盒',
            count: '1',
            username: '花花'
        }]
    },
    onLoad: function() {
        var that = this;
        wx.getSystemInfo({
            success: function(res) {
                that.setData({
                    sliderLeft: (res.windowWidth / that.data.tabs.length - sliderWidth) / 2,
                    sliderOffset: res.windowWidth / that.data.tabs.length * that.data.activeIndex
                });
            }
        });
    },
    tabClick: function(e) {
        this.setData({
            sliderOffset: e.currentTarget.offsetLeft,
            activeIndex: e.currentTarget.id
        });
    },
    //订单点击事件
    itemClick: function(e) {
        //订单id
        let orderId = e.currentTarget.dataset.orderid;
        console.log(orderId);
        wx.navigateTo({
          url: '/pages/orderDetail/orderDetail?orderId=' + orderId
        })
    }
});